// 正则 ==> [00:00.000]
const timePattern = /\[(\d{2}):(\d{2})\.(\d{2,3})\]/
export function parseLyric(lyricString) {
    const lyricStrings = lyricString.split('\n')
    const parseLyricArr = []
    for (const lineString of lyricStrings) {
        // [00:00.000] 作词 : 队长
        const timeResult = timePattern.exec(lineString)
        if (!timeResult) continue
        const minute = timeResult[1] * 60 * 1000
        const second = timeResult[2] * 1000
        const millsecond = timeResult[3].length === 2 ? timeResult[3] * 10 : timeResult[3] * 1
        // 歌曲时间
        const time = minute + second + millsecond
        // 歌曲文本
        const lyricText = lineString.replace(timeResult[0], '')
        // 将事件和歌词放入一个对象中
        const lyricInfo = {
            time,
            lyricText
        }
        parseLyricArr.push(lyricInfo)
    }
    return parseLyricArr
}